<!-- 分配任务提醒 -->
<template>
  <div id="dialog-container">
    <el-button type="primary" size="mini" @click="dialogVisible = true">分配任务</el-button>
    <el-dialog v-dialogDrag :title="'分配任务用户选择操作提示'" append-to-body :visible.sync="dialogVisible" :close-on-click-modal="false"
      width="680px">
      <el-form :model="formData" :inline="true" size="small">
        <el-row>
          <el-col :span="11">
            <el-form-item label="用户姓名">
              <el-input v-model="formData.name"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="工号">
              <el-input v-model="formData.number"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="2" :offset="1">
            <el-form-item>
              <el-button type="primary" plain>查询</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <br>
      <el-table ref="multipleTable" :data="tableData" border @selection-change="handleSelectionChange">
        <el-table-column type="selection" align="center" width="40"></el-table-column>
        <el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
        <el-table-column prop="date" label="工号" width="120"></el-table-column>
        <el-table-column prop="name" label="用户姓名" width="150"></el-table-column>
        <el-table-column prop="address" label="角色"></el-table-column>
      </el-table>
      <jt-easy-pagination></jt-easy-pagination>

      <assigned-reminder :show.sync="isShowAssigned"></assigned-reminder>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="dialogVisible = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import JtEasyPagination from 'components/jt-easy-pagination/index';
import AssignedReminder from './assigned-reminder';
  export default {
    data() {
      return {
        dialogVisible: false,
        formData: {
          name: '',
          number: ''
        },
        tableData: [{
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        }, {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }, {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄'
        }],
        mulSelection: 0,
        isShowAssigned: false
      }
    },
    components:{
        'jt-easy-pagination':JtEasyPagination,
        'assigned-reminder': AssignedReminder
    },
    methods: {
      handleSelectionChange(val) {
        this.mulSelection = val.length;
      },
      submitForm() {
        if(this.mulSelection == 0) {
          this.$alert('请选择一条用户信息', '操作提示', {
            confirmButtonText: '确定',
            type: 'warning'
          });
          return;
        } else if(this.mulSelection > 1) {
          this.$alert('只能分配给一个用户', '操作提示', {
            confirmButtonText: '确定',
            type: 'warning'
          });
          return;
        } else {
          // 分配结果显示
          this.isShowAssigned = true;
          this.dialogVisible = false;
        }
      }
    }
  }

</script>
